<article id="wikiArticle">
<div></div>
<p>@@iterator 的初始值是和 <a href="Reference/Global_Objects/TypedArray/values" title="values()返回新的 Array Iterator 对象，包含数组中每个下标处的值。"><code>values</code></a> 属性的初始值相同的对象。</p>
<h2 id="语法">语法</h2>
<pre><code class="language-javascript"><code><var>arr</var>[Symbol.iterator]()</code></code></pre>
<h3 id="返回值">返回值</h3>
<p>数组的 <strong>迭代器</strong> 函数，通常是 <a href="Reference/Global_Objects/TypedArray/values" title="values()返回新的 Array Iterator 对象，包含数组中每个下标处的值。"><code>values()</code></a>函数。</p>
<h2 id="示例">示例</h2>
<h3 id="使用for...of_循环的迭代">使用<code>for...of</code> 循环的迭代</h3>
<pre><code  class="language-javascript">var arr = new Uint8Array([10, 20, 30, 40, 50]);
// 你的浏览器必须支持 for..of 循环
// 以及 for 循环中的 let 区域变量
for (let n of arr) {
  console.log(n);
}
</code></pre>
<h3 id="备选迭代">备选迭代</h3>
<pre><code  class="language-javascript">var arr = new Uint8Array([10, 20, 30, 40, 50]);
var eArr = arr[Symbol.iterator]();
console.log(eArr.next().value); // 10
console.log(eArr.next().value); // 20
console.log(eArr.next().value); // 30
console.log(eArr.next().value); // 40
console.log(eArr.next().value); // 50
</code></pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-%typedarray%.prototype-@@iterator" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">%TypedArray%.prototype[@@iterator]()</small></a></td>
<td><span class="spec-Standard">Standard</span></td>
<td>初始定义。</td>
</tr>
<tr>
<td><a class="external" href="https://tc39.github.io/ecma262/#sec-%typedarray%.prototype-@@iterator" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">%TypedArray%.prototype[@@iterator]()</small></a></td>
<td><span class="spec-Draft">Draft</span></td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<div><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
            This compatibility table still uses the old format,
            because we haven't yet converted the data it contains.
            <strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div></div>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><a href="/en-US/Firefox/Releases/36" title="Released on 2015-02-24.">36</a> (36) [1]</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td>36.0 (36) [1]</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
</tr>
</tbody>
</table>
</div>
<p>[1] 从 Gecko 17 (Firefox 17 / Thunderbird 17 / SeaMonkey 2.14) 到 Gecko 26 (Firefox 26 / Thunderbird 26 / SeaMonkey 2.23 / Firefox OS 1.2) 使用 <code>iterator</code> 属性 (<a class="external" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907077" rel="noopener">bug 907077</a>)，从 Gecko 27 到 Gecko 35 使用<code>"@@iterator"</code> 占位符。 在 Gecko 36 (Firefox 36 / Thunderbird 36 / SeaMonkey 2.33)中，<code>@@iterator</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol">Symbol</a> 予以实现(<a class="external" href="https://bugzilla.mozilla.org/show_bug.cgi?id=918828" rel="noopener">bug 918828</a>)。</p>
<h2 id="See_also">See also</h2>
<ul>
<li><a href="/en-US/docs/Web/JavaScript/Typed_arrays">JavaScript typed arrays</a></li>
<li><a href="Reference/Global_Objects/TypedArray" title="一个TypedArray 对象描述一个底层的二进制数据缓存区的一个类似数组(array-like)视图。事实上，没有名为 TypedArray的全局对象，也没有一个名为的 TypedArray构造函数。相反，有许多不同的全局对象，下面会列出这些针对特定元素类型的类型化数组的构造函数。在下面的页面中，你会找到一些不管什么类型都公用的属性和方法。"><code>TypedArray</code></a></li>
<li><a href="Reference/Global_Objects/TypedArray/entries" title="The entries()返回新的Array Iterator对象，包含数组每个下标处的键值对。"><code>TypedArray.prototype.entries()</code></a></li>
<li><a href="Reference/Global_Objects/TypedArray/keys" title="keys()方法返回新的 Array Iterator 对象，包含数组中每个下标的键。"><code>TypedArray.prototype.keys()</code></a></li>
<li><a href="Reference/Global_Objects/TypedArray/values" title="values()返回新的 Array Iterator 对象，包含数组中每个下标处的值。"><code>TypedArray.prototype.values()</code></a></li>
</ul>
</article>